* Replication code for Aarøe, Petersen and Arceneaux (2017) US YouGov 2014 Sample *

* This do file reproduces analyses related to the US YouGov 2014 Sample (reported in Online Appendix A4.3.1)
* Use the following replication data set: "Replication Data Set US YouGov 2014 Sample"
** See the Online Appendix A4.3.1 for details on question wording 

set more off

******************************************************************************************************
* recodings and reliability code reported here
******************************************************************************************************

* creation of the contamination disgust scale (ranging from 0 to 1)
cor  q1c_1 q1c_2 q1d_1 q1d_2 q1d_3
sum q1c_1
sum q1d_1
cor  q1c_1 q1c_2 q1d_1 q1d_2 q1d_3
egen contamination = rmean (q1c_1 q1c_2 q1d_1 q1d_2 q1d_3)
gen contamination01=contamination/4
ta contamination01

* Crohnbachs' alpha reliability coefficient for the contamination disgust scale
alpha q1c_1 q1c_2 q1d_1 q1d_2 q1d_3

* Creation of the Pathogen Disgust Scale (ranging from 0 to 1)
cor q1b_1 q1b_2 q1b_3 q1b_4 q1b_5 q1b_6 q1b_7
egen pathogen =rmean( q1b_1 q1b_2 q1b_3 q1b_4 q1b_5 q1b_6 q1b_7)
gen pathogen01=(pathogen-1)/6
ta pathogen01

* Crohnbachs' alpha reliability coefficient for the pathogen disgust scale 
alpha  q1b_1 q1b_2 q1b_3 q1b_4 q1b_5 q1b_6 q1b_7 

* Creation of the germ aversion factor (ranging from 0 to 1)
recode  q1a_5 (7=1) (6=2) (5=3) (4=4) (3=5) (2=6) (1=7), gen (q1a_5rc)
recode  q1a_7 q1a_8 (7=1) (6=2) (5=3) (4=4) (3=5) (2=6) (1=7), gen (q1a_7rc q1a_8rc)

egen germaversion=rmean(q1a_1 q1a_2 q1a_3 q1a_4 q1a_5rc q1a_6 q1a_7rc q1a_8rc)
gen germaversion01=(germaversion-1)/6
ta germaversion01

* Crohnbachs' alpha reliability coefficient for the germ aversion factor 
alpha  q1a_1 q1a_2 q1a_3 q1a_4 q1a_5rc q1a_6 q1a_7rc q1a_8rc

* Creation of the composite measure of behavioral immune sensitivity
egen compositescale = rmean(contamination01 pathogen01 germaversion01)

* Crohnbachs' alpha reliability coefficient for the composite measure of behavioral immune sensitivity
alpha contamination01 pathogen01 germaversion01

* Experimental treatment variable: Placement of disgust questions (1 = "placed first" condition, 0 = "placed last" condition)
gen placement= experiment
recode placement (2=0)
label define placement 0 "placed last" 1 "placed first"
label values placement placement

*opposition toward immigration ranging from 0 to 1
egen immig=rmean(q2_8a q2_8d)
gen immig01=(immig-1)/6
sum immig01

*ideology ranging from 0 to 1
gen ideo01=(q4-1)/6

*household income ranging from 0 to 1
gen income =household_income
recode income (97=.)
gen income01 =(income-1)/11

* female
gen female = gender-1

*education ranging from 0 to 1
gen education01=(education-1)/5

*race (0 = Caucasian/white, 1 = other ethnic and racial minorities)
gen nonwhite=.
replace nonwhite =1 if race ==1
replace nonwhite = 0 if race !=1
replace nonwhite =. if race ==.


***********************************************************
*Results 
***********************************************************

* Online Appendix A4.3.1, Table A4 - effect of the placement of behavioral immune sensitivity measures
eststo: reg immig01  c.placement 
eststo: reg immig01 c.placement female age education01 income01 ideo01 nonwhite
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.1 ** 0.02 *** 0.002) wide constant ar2


* Online Appendix A4.3.1, footnote 6 Replicating the analysis in Test 1, Table 2 in the US YouGov 2014 Sample
reg immig01 c.compositescale female age education01 income01 ideo01 nonwhite
reg immig01 c.contamination01 female age education01 income01 ideo01 nonwhite
reg immig01 c.pathogen01 female age education01 income01 ideo01 nonwhite
reg immig01 c.germaversion01 female age education01 income01 ideo01 nonwhite
